home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK2.toast / Development Kits (Disc 2) / QuickTime / Programming Stuff / Sample Code / Music Architecture / Mixed Bag / BigEasy / BigEasyUtils.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-11  |  1.8 KB  |  116 lines  |  [TEXT/KAHL]

  1. /*
  2.     File:        BigEasyUtils.c
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    xxx put writers here xxx
  7.  
  8.     Copyright:    
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <2>    11-10-94    dvb        GetModKeys
  13.  
  14. */
  15.  
  16. /* file: BigEasyUtils.c
  17.   *
  18.   * Started 25 January 1992, more or less.
  19.   *
  20.   * Little Extras that go
  21.   * well with BigEasy.
  22.   *
  23.   */
  24.  
  25.  
  26. /*----------------
  27.     Inclusions
  28. ----------------*/
  29.  
  30.  
  31. #include "BigEasy2.h"
  32. #include "BigEasyUtils.h"
  33.  
  34.  
  35. /*----------------
  36.     Dofu
  37. ----------------*/
  38.  
  39.  
  40. void SetMenuItemRange(short loRef,short hiRef,short active,short bulletRef)
  41. /*
  42.  * Set the range of menu-refs passed to either
  43.  * active or inactive (±1) and bullet the
  44.  * one that matches 'bulletref'
  45.  */
  46.     {
  47.     short i;
  48.  
  49.     for(i = loRef; i<= hiRef; i++)
  50.         SetMenuItem(i,active,SignIt(bulletRef == i),'•',nil);
  51.     }
  52.  
  53.  
  54.  
  55. #ifdef THINK_C
  56.     long RememberThis(long what,short which)
  57.     /*
  58.      * To store something, pass what, and a negative "which".
  59.      * To retrieve it, pass the positive which.
  60.      */
  61.         {
  62.         asm    {
  63.             LEA        @them,A0
  64.             MOVE    which,D0
  65.             ADD        D0,D0
  66.             ADD        D0,D0
  67.             BMI.S    @stash
  68.             ADDA    D0,A0
  69.             MOVE.L    (A0),D0
  70.             BRA.S    @done
  71.     @stash:
  72.             SUBA    D0,A0
  73.             MOVE.L    what,(A0)
  74.             MOVE.L    what,D0
  75.             BRA.S    @done
  76.     
  77.     @them    DC.L    0,0,0,0,0,0,0,0,0,0,0
  78.     
  79.     @done:
  80.             }
  81.         }
  82. #endif
  83.  
  84.  
  85. void CenterRect(Rect *centerThis,Rect *insideThis)
  86.     {
  87.     OffsetRect(centerThis,
  88.             (insideThis->left + insideThis->right - centerThis->left - centerThis->right)>>1,
  89.             (insideThis->top + insideThis->bottom - centerThis->top - centerThis->bottom)>>1);
  90.     }
  91.  
  92.  
  93.  
  94. short GetModKeys(void)
  95. /*
  96.  * return the modifier keys just like in an eventrecord
  97.  */
  98.     {
  99.     short result;
  100.     KeyMap keys;
  101.  
  102.     GetKeys(keys);
  103.  
  104.     result = 0;
  105.     if(keys[1] & 1)
  106.         result |= shiftKey;
  107.     if(keys[1] & 4)
  108.         result |= optionKey;
  109.     if(keys[1] & 8)
  110.         result |= controlKey;
  111.     if(keys[1] & 0x8000)
  112.         result |= cmdKey;
  113.  
  114.     return result;
  115.     }
  116.